<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <script type="text/javascript" src="${ctx}/appjs/printer/printer.js"></script>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<br>' +
            '<ol class="breadcrumb">' +
            '<li>' +
            '<a>打印机</a>' +
            '</li>' +
            '<li>' +
            '<a>打印机</a>' +
            '</li>' +
            '<li>' +
            '<strong>添加打印机</strong>' +
            '</li>' +
            '</ol>';
    });
</script>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>增加</h5>
                    <ul class="nav navbar-top-links navbar-right">
                        <li>
                            <span class="m-r-sm text-muted welcome-message"><a
                                    href="javascript:window.history.back()"><i class="fa fa-home"></i> 返回</a></span>
                        </li>
                    </ul>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="frmAdd">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">桩群名称:</label>
                            <div class="col-sm-8">
                                <select name="epgId" id="epgId"
                                        class="form-control chosen-select"
                                        style="width: 100%">
                                    <option value="" selected="selected">--请选择--</option>
                                    <c:forEach items="${pileGroups}" var="bean">
                                        <option value="${bean.elecStationId}">${bean.stationName}(${bean.addressDetail})
                                        </option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label " >打印机逻辑地址(格式: 00 00 00 00):</label>
                            <div class="col-sm-8">
                            <input id="priRtua" name="priRtua" class="form-control" maxlength="11"  type="text"
                                   <%--onkeyup="this.value =this.value.replace(/\s/g,'').replace(/[^\d]/g,'').replace(/(\d{2})(?=\d)/g,'$1 ');"--%> autocomplete="off">
                        </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">可打印次数：</label>
                            <div class="col-sm-8">
                                <input id="priTime" name="priTime" class="form-control"
                                type="number" min="1" max="99999" onkeyup="value=value.replace(/[^\d]/g,'')" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">警告提示数：</label>
                            <div class="col-sm-8">
                                <input id="warncount" name="warncount" class="form-control"
                                       type="number" min="1" max="99999" onkeyup="value=value.replace(/[^\d]/g,'')" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-success">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    addprinter.init();
</script>

<%--<script>--%>
    <%--$(function() {--%>
        <%--$('#priRtua').on('keyup', function(e) {--%>
            <%--//只对输入数字时进行处理--%>
            <%--if((e.which >= 48 && e.which <= 57) ||--%>
                <%--(e.which >= 96 && e.which <= 105 )){--%>
                <%--//获取当前光标的位置--%>
                <%--var caret = this.selectionStart--%>
                <%--//获取当前的value--%>
                <%--var value = this.value--%>
                <%--//从左边沿到坐标之间的空格数--%>
                <%--var sp = (value.slice(0, caret).match(/\s/g) || []).length--%>
                <%--//去掉所有空格--%>
                <%--var nospace = value.replace(/\s/g, '')--%>
                <%--//重新插入空格--%>
                <%--var curVal = this.value = nospace.replace(/(\d{2})/g, "$1 ").trim()--%>
                <%--//从左边沿到原坐标之间的空格数--%>
                <%--var curSp = (curVal.slice(0, caret).match(/\s/g) || []).length--%>
                <%--//修正光标位置--%>
                <%--this.selectionEnd = this.selectionStart = caret + curSp - sp--%>

            <%--}--%>
        <%--})--%>
    <%--})--%>
<%--</script>--%>

<script type="text/javascript">
    priTime
</script>
<script type="text/javascript">
    $("#priRtua").on('input propertychange',function () {
        $(this).val($(this).val().replace(/\s/g,'').replace(/[^\d]/g,'').replace(/(\d{2})(?=\d)/g,'$1 '));
    })
</script>
</body>
</html>
